// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement;

public sealed partial class IndexSegmentSort
{
	[JsonInclude, JsonPropertyName("field")]
	[JsonConverter(typeof(SingleOrManyFieldsConverter))]
	public Elastic.Clients.Elasticsearch.Serverless.Fields? Field { get; set; }
	[JsonInclude, JsonPropertyName("missing")]
	[SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing))]
	public ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>? Missing { get; set; }
	[JsonInclude, JsonPropertyName("mode")]
	[SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode))]
	public ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>? Mode { get; set; }
	[JsonInclude, JsonPropertyName("order")]
	[SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder))]
	public ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>? Order { get; set; }
}

public sealed partial class IndexSegmentSortDescriptor<TDocument> : SerializableDescriptor<IndexSegmentSortDescriptor<TDocument>>
{
	internal IndexSegmentSortDescriptor(Action<IndexSegmentSortDescriptor<TDocument>> configure) => configure.Invoke(this);

	public IndexSegmentSortDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.Fields? FieldValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>? MissingValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>? ModeValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>? OrderValue { get; set; }

	public IndexSegmentSortDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Serverless.Fields? field)
	{
		FieldValue = field;
		return Self;
	}

	public IndexSegmentSortDescriptor<TDocument> Missing(ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>? missing)
	{
		MissingValue = missing;
		return Self;
	}

	public IndexSegmentSortDescriptor<TDocument> Mode(ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>? mode)
	{
		ModeValue = mode;
		return Self;
	}

	public IndexSegmentSortDescriptor<TDocument> Order(ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>? order)
	{
		OrderValue = order;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (FieldValue is not null)
		{
			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
		}

		if (MissingValue is not null)
		{
			writer.WritePropertyName("missing");
			SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>(MissingValue, writer, options);
		}

		if (ModeValue is not null)
		{
			writer.WritePropertyName("mode");
			SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>(ModeValue, writer, options);
		}

		if (OrderValue is not null)
		{
			writer.WritePropertyName("order");
			SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>(OrderValue, writer, options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class IndexSegmentSortDescriptor : SerializableDescriptor<IndexSegmentSortDescriptor>
{
	internal IndexSegmentSortDescriptor(Action<IndexSegmentSortDescriptor> configure) => configure.Invoke(this);

	public IndexSegmentSortDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.Fields? FieldValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>? MissingValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>? ModeValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>? OrderValue { get; set; }

	public IndexSegmentSortDescriptor Field(Elastic.Clients.Elasticsearch.Serverless.Fields? field)
	{
		FieldValue = field;
		return Self;
	}

	public IndexSegmentSortDescriptor Missing(ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>? missing)
	{
		MissingValue = missing;
		return Self;
	}

	public IndexSegmentSortDescriptor Mode(ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>? mode)
	{
		ModeValue = mode;
		return Self;
	}

	public IndexSegmentSortDescriptor Order(ICollection<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>? order)
	{
		OrderValue = order;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (FieldValue is not null)
		{
			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
		}

		if (MissingValue is not null)
		{
			writer.WritePropertyName("missing");
			SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>(MissingValue, writer, options);
		}

		if (ModeValue is not null)
		{
			writer.WritePropertyName("mode");
			SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>(ModeValue, writer, options);
		}

		if (OrderValue is not null)
		{
			writer.WritePropertyName("order");
			SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>(OrderValue, writer, options);
		}

		writer.WriteEndObject();
	}
}